package com.bookstore.service;


import com.bookstore.entity.Category;
import com.bookstore.mapper.CategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryService {

    @Autowired(required = false)
    CategoryMapper categoryMapper;

    public List<Category> getAllCategory(){
        List<Category> list = categoryMapper.getAllCategory();
        return list;
    }

    /**
     * 查询二级分类
     * @param pId 父类Id
     * @return
     */
    public List<Category> getCategoryByPid(Long pId){
        List<Category> categoryList = categoryMapper.getCategoryByPID(pId);
        return categoryList;
    }

    public Category getCategoryByCid(Long cId){
        Category category = categoryMapper.selectByPrimaryKey(cId);
        return category;
    }

}
